package com.wyq.action;

import java.util.List;
import java.util.Map;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.wyq.bean.Audience_Q;
import com.wyq.bean.Audience_Qtitle;
import com.wyq.bean.ShowInfo;
import com.wyq.service.AudienceQService;
import com.wyq.service.ShowInfoService;
import com.wyq.util.PropertiesUtil;

/**
 * 前台获取调查问卷信息
 * @author Fyj
 */
public class PreAudienceQInfoAction extends ActionSupport{
	private String source;//展会渠道
	private Map showInfo;//展会信息
	
	private AudienceQService audienceQService;
	private ShowInfoService showInfoService;
	
	@Override
	public String execute() throws Exception {
		//获取展会信息
		String show_id = "";
		List<Map> showInfos = showInfoService.getShowInfoByTypeOrUrlChannel(null, source);
		if(null != showInfos && showInfos.size()>0){
			Map domain = (Map)showInfos.get(0);
			showInfo = domain;
			show_id = domain.get("id")!= null?domain.get("id").toString():"";
		}
		
		Audience_Qtitle qTitle = new Audience_Qtitle();
		qTitle.setQtitle("得知该网站的途径");
		qTitle.setIsAvalible(1);
		
		Audience_Q q = new Audience_Q();
		q.setQtext("网络");
		q.setIsAvalible(1);
		qTitle.getAudienceQs().add(q);
		q.setAudienceQtitle(qTitle);
		
		//audienceQService.saveAudienceQtitle(qTitle);
		
		Map request = (Map)ActionContext.getContext().get("request");
		List QtitleList = audienceQService.findAllAudience_Qtitle(show_id);
		System.out.println(QtitleList);
		//List QList = audienceQService.findAllAudience_Q();
		request.put("qTitleList", QtitleList);
		//request.put("qList", QList);
		return "success";
	}

	public String getSource() {
		return source;
	}

	public void setSource(String source) {
		this.source = source;
	}
	public void setAudienceQService(AudienceQService audienceQService) {
		this.audienceQService = audienceQService;
	}

	public void setShowInfoService(ShowInfoService showInfoService) {
		this.showInfoService = showInfoService;
	}

	public Map getShowInfo() {
		return showInfo;
	}

}
